//
//  ITURLManager.m
//  GLPFinance
//
//  Created by ITBE on 16/10/28.
//  Copyright © 2016年 intube. All rights reserved.
//

#import "ITURLManager.h"
#import "ITUserManager.h"
#define UrlWithStateKey @"UrlWithStateKey"

static ITURLManager *manager = nil;
@implementation ITURLManager
+(instancetype)defaultManager
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (manager == nil) {
            manager = [[ITURLManager alloc] init];
        }
    });
    return manager;
}

- (instancetype)init{
    self = [super init];
    if (self) {
#ifdef DEBUG
        NSString *state = [[NSUserDefaults standardUserDefaults] objectForKey:UrlWithStateKey];
        //state = @"0";
        if (state == nil) {
            self.urlWithState = 0;
        }else {
            self.urlWithState = state.intValue;
        }
        if (_urlWithState != state.intValue) {
            [ITUserManager.shareManager removeLocalHostMemberData];
        }
#else
        self.urlWithState = 0;
#endif
    }
    return self;
}

-(NSString *)returnBaseUrl
{
    return _baseURL;
}

- (void)setUrlWithState:(NSInteger)urlWithState
{
    _urlWithState = urlWithState;
    switch (_urlWithState) {
        case 0:{
            //_baseURL = @"https://api.walktus.com/walk";
            _baseURL = @"https://api.ivideoquiz.com/quiz";

            //_clientPri = @"MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAKVQCI4eEGQpasFucRjkN5Bz9g/O0noX7EkLzP9imNKNWVT94LaryFNsUeyW/BGO77oxwIPpWbXqePA3XqFlOFI5esDJpWf8FrFPQs3bYwZj0k5r+7M7M/XURSQwAMgR4+1G0bFGTIvxcN7IgUF3KtPS1/818H7aRT2k5+oWUmxDAgMBAAECgYBviXJcQRiaG/+1hwiz3LdItZTd0ZPdYOrB1j54SVQHK+uMFsdZOMouzzTvRmfIiQJiRFM6LWWkAhGbMiCdEKhQaym1Co+brHPL4yewg2rB3BRipo2iSAlo/4GM5ZXX04yR1rlDs2+JvTr4HKtYD+eomtjFb/c/7sIvU+CSyAswwQJBAOJ1MOOd5Vaj27jSkPPhkT1WBh7zYXDqIy8s9S9MI06s0S915tfw7qp8/NQ2VIhJeSO54LMz1wNCBFnQu/fxmvMCQQC64NUU3NQsc34LgSggDNaSNwwhikb9KBxCQ7rY54N3AvkahlpI0rt1it1t0T/L+KL6+aq3atnBw7NwlXriQp1xAkAwS+AOW0ljDfU5WKcTbEMGesc5aJyacUTptcPgv3M0P0UpwxJlcXvlHlzpgWDL5CeSx/y1G1Q63KSC5zJ/caajAkAYhpNQdp7d6pZbOisi8axjahgMetJQPShgRfVKrC+jud8pbQKCVi3GAmCHHhQqV8pD9+pAwiQr+twc5XFIKofxAkAAgopyT3q7FxNPI/LUK2yyA0OdbEY9EndQJ6R6shHA9VpQKpLtLgE9aQk9R/Cjs30ZOmwwl2icbsRYcYC40f1s";
            
            //_clientPub = @"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtpaD0dM7XVpA51dmMQp/pPDLj0bp7/z7nXS/PdXMbHQ9YXTqAKU0/gl1KlU0QVIXZrVUGqeFXopE3jy2mP3iolQqspkkpef/ETmmxXWD6LkrJyM+iQvU50ozskoPc9pPn72f4/GawjWaLqacuWyoqFRPU7nYY0sxFDqrCjAPG4wIDAQAB";
        }
            break;
            
        case 1:{
            
            //_baseURL = @"http://10.10.1.111:8099/InVid";
            //_baseURL = @"http://47.103.132.200:8100/walk";
            _baseURL = @"http://47.101.216.4:8080/quiz";
            
            //_clientPri = @"MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAIeHk2xm8M9hmwkgYI/kHAI5nnWrBHuKvpRzd/ffiRWWmfbOkN3pw/PCVYTXUKieYFGA/sMUaAmtd6BlURLSsYLXqEPSvBHbI29T7n4nYACfQtlNGHy3U4QbUxGVVd8WgVprY9hEq2gsguwRUL43llpmjtNndyoTIrcOBLcckbEDAgMBAAECgYAdzcaxtAGI2WIKo8AYZIV0R898+NrHgD9gzfO34sR2puO8zrg01M9ur3G3ANKQAiQUSFW9+KLYXflMoHsvtH2sgmnXrfH/szTUtHC1vtzXEr4/azUeLq9/tCmrIkGwQumscTNux0xSHX+kIzRDbfiG+Kg4O2EMhtOICWVLSEndYQJBALzO4rdDQjSTHWW/9q0XRE3D1A8xbK8pgBhXznVWYOF4gAZyGweKXX94RFO0idBpscmfZa3ftXub87fHAqfBBp0CQQC3wtGWE+NhtHyuWh3CkavpqndBFyPb3nHvWMdsyl9cJlnhpIGT5kG1dzGH40fnEZI17KRMydU5hhKdRPCuIjQfAkB8HplGFo4QV+IMgLyeH1yErsbaUgh7whF2b0rHMkiwEHJBSoPgWiKK6LoqONYcT09UF1hVjGoW33fBia+CLk+1AkAqjtoPUefVVwGRN5mw2B/ia/JWhs9tOmVUs1DsZyoSo2cplPnVkPwi1MoJ2J9samtcRcP/bLcPLXfeKHs9OPqtAkAeXuQhW6ML4We/xwOjE8iNvxBCeGa6UoFwKPy86fga7bk+HXALlibtXnssat9ViKdTJup23piWs6iRbebbZUjE";
            //_clientPub =  @"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDL/u3gvDRR/1LMXAuz37d1vdvxh4YO3qbG4+WKOSUHWZ/IrYhIOv44myNy0hbfITwgJfNcgrB3Qor2Ppz8VuCPHBnaG44haoafcl1JfjDiw+xXBXdQNJQJl7HD/W/Vs940bqCRUemK/Z68Cav0SfmHh6MFqvA3KnePP7s3eia21wIDAQAB";
        }
            break;
            
        default:
            break;
    }
    [NSUserDefaults saveValue:@(_urlWithState) forKey:UrlWithStateKey];
}
@end
